/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.repository.model.knowledge;
import cn.ac.nercis.pes.common.utils.JsonUtils;
import cn.ac.nercis.pes.common.constant.evaluation.EvaluationConclusion;
import cn.ac.nercis.pes.common.constant.evaluation.EvaluationItem;
import cn.ac.nercis.pes.repository.constant.BaseConstants;
import cn.ac.nercis.pes.repository.converter.evaluation.EvaluationConclusionConverter;
import cn.ac.nercis.pes.repository.converter.evaluation.EvaluationItemConverter;
import cn.ac.nercis.pes.repository.model.base.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;

/**
 * 预期结果信息实体类（知识库）
 *
 * @author zpy
 * @version 1.0.0
 */
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "km_expected_result")
public class KmExpectedResultDO extends BaseEntity {
    @Id
    @GenericGenerator(name = "generator",strategy = BaseConstants.CUSTOM_UUID_STRATEGY)
    @GeneratedValue(generator = "generator")
    @Column(name = "id", unique = true, nullable = false, length = 36)
    private String id;

    @Column(name = "layer_target", nullable = false, length = 500)
    private String layerTarget;

    @Column(name = "unit_target", nullable = false, length = 500)
    private String unitTarget;

    @Column(name = "asset_class_id", nullable = false, length = 36)
    private String assetClassId;

    @Column(name = "asset_type", nullable = false, length = 500)
    private String assetType;

    @Convert(converter = EvaluationItemConverter.class)
    @Column(name = "eval_item", nullable = false)
    private EvaluationItem evalItem;

    @Convert(converter = EvaluationConclusionConverter.class)
    @Column(name = "eval_conclusion", nullable = false)
    private EvaluationConclusion evalConclusion;

    @Column(name = "result", nullable = false, length = 2000)
    private String result;

    @Column(name = "useCount", nullable = false)
    private Long useCount;

    @Override
    public String toString() {
        return this.getClass().getSimpleName().concat(JsonUtils.toJson(this));
    }
}